﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XStudio.XCRF.Data.Entities;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Validation;

namespace XStudio.XCRF.Data.Business.Validate
{
    /// <summary>
    /// 表示业务逻辑实体权限验证的特性
    /// </summary>
    public abstract class ValidateAttribute : Attribute
    {
        /// <summary>
        /// 验证添加
        /// </summary>
        /// <param name="entityEntry"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual IEnumerable<DbValidationError> ValidateAdd(DbEntityEntry entityEntry, XCRFContext context)
        {
            return new List<DbValidationError>();
        }
        /// <summary>
        /// 验证编辑
        /// </summary>
        /// <param name="entityEntry"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual IEnumerable<DbValidationError> ValidateEdit(DbEntityEntry entityEntry, XCRFContext context)
        {
            return new List<DbValidationError>();
        }
        /// <summary>
        /// 验证删除
        /// </summary>
        /// <param name="entityEntry"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual IEnumerable<DbValidationError> ValidateDelete(DbEntityEntry entityEntry, XCRFContext context)
        {
            return new List<DbValidationError>();
        }
    }
}
